package xml;


import com.xctech.yace.factory.WeightBinaryFactory;
import lombok.SneakyThrows;

public class demo {

//    public static String toBinary(int num, int digits) {
//        int value = 1 << digits | num;
//        String bs = Integer.toBinaryString(value); //0x20 | 这个是为了保证这个string长度是6位数
//        return  bs.substring(1);
//    }

//    public static void main(String[] args) {
//        StringBuilder sb = null;
//
//        Object[] element = {'A','B','C','D','E','F','G','H'};
//        int m = 0;
//        int n = 1;
//        int bit = 8;
//        do {
//            sb = new StringBuilder();
//            m = (2 << bit) - n;
//            String bt = toBinary(m, 8);
//            char[] cs = bt.toCharArray();
//            for(int i = 0;i < cs.length ;i++){
//                Object o = cs[i] == '1' ? element[i] : -1;
//                sb.append(o);
//                sb.append("_");
//            }
//            System.out.println(sb.deleteCharAt(sb.length()-1));
//            n++;
//        }while (m > 0);
//    }

    @SneakyThrows
    public static void main(String[] args) {
//        WeightBinaryFactory instance = WeightBinaryFactory.getInstance('1','2','3','4');
//        WeightBinaryFactory instance = WeightBinaryFactory.getInstance();
//        for(int i =0;i<10;i++){
//            System.out.println(instance.read());
//            Thread.sleep(3000);
//        }
//        instance = WeightBinaryFactory.getInstance('A','B','C','D');
//        for(int i =0;i<10;i++){
//            System.out.println(instance.read());
//            Thread.sleep(3000);
//        }
        WeightBinaryFactory in = WeightBinaryFactory.getInstance('A', 'B', 'C', 'D');
        String target;
        while((target = in.read()) != null){
            System.out.println(target);
        }
    }
}
